<link rel="stylesheet" type="text/css" href="/nav/static/wxapp/mui.css" />
<link rel="stylesheet" type="text/css" href="/nav/static/layer_mobile/need/layer.css" />
<link rel="stylesheet" type="text/css" href="http://cache.amap.com/lbs/static/main1119.css"/>
<script type="text/javascript" src="/nav/static/public/js/jquery.js"></script>
<script type="text/javascript" src="/nav/static/layer_mobile/layer.js"></script>
<script type="text/javascript" src="/nav/static/wxapp/mui.js"></script>
<script src="http://cache.amap.com/lbs/static/es5.min.js"></script>
<script src="http://webapi.amap.com/maps?v=1.3&key=baf1a971f3daf5c0d0095ef48ccb6479"></script>
<script id="ajax"></script>
<script>
    var map = null;
    var marker = null;
    var lng = null;
    var lat = null;
    var province = null;
    var city = null;
    var area = null;
    var address = null;

    //解析定位结果
    function onComplete(data) {
        lng = data.position.getLng();
        lat = data.position.getLat();
        var citycode = data.addressComponent;
        province = citycode.province;
        city = citycode.city;
        area = citycode.district;
        address = data.formattedAddress;
        $("#ajax").attr("src",domain+'app/login/update_address?token='+token+'&province='+province+'&city='+city+'&area='+area);
    }

    //解析定位错误信息
    function onError(data) {
        alert(data.message);
    }

    //标记
    function addMarker(lng,lat,type) {
        if(type){
            icon = '/nav/static/wxapp/position.png';
        }else{
            icon = '/nav/static/admin/images/express.png';
        }
        marker = new AMap.Marker({
            icon: icon,
            position: [lng,lat]
        });
        marker.setMap(map);
        if(type){
            //marker.setAnimation('AMAP_ANIMATION_BOUNCE');
            infoWindow = new AMap.InfoWindow({
                offset: new AMap.Pixel(0, -20),
                content: address  //使用默认信息窗体框样式，显示信息内容
            });
            infoWindow.open(map, map.getCenter());
        }
    }
    
    //定位
    function get_location() {
        mapObj = new AMap.Map('iCenter');
        mapObj.plugin('AMap.Geolocation', function () {
            geolocation = new AMap.Geolocation({
                enableHighAccuracy: true,//是否使用高精度定位，默认:true
                timeout: 10000,          //超过10秒后停止定位，默认：无穷大
                maximumAge: 0,           //定位结果缓存0毫秒，默认：0
                convert: true,           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
                showButton: true,        //显示定位按钮，默认：true
                buttonPosition: 'LB',    //定位按钮停靠位置，默认：'LB'，左下角
                buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
                showMarker: true,        //定位成功后在定位到的位置显示点标记，默认：true
                showCircle: true,        //定位成功后用圆圈表示定位精度范围，默认：true
                panToLocation: true,     //定位成功后将定位到的位置作为地图中心点，默认：true
                zoomToAccuracy:true      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
            });
            mapObj.addControl(geolocation);
            geolocation.getCurrentPosition();
            AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
            AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
        });
    }

    //请求url
    var domain = 'http://niu.wm0530.com/nav/';

    //获取附近跑客
    var express_nearby_list = 'app/express/nearby_list';

    //获取跑腿费
    var user_count_charge = 'app/user/count_charge';

    //帮我买
    var user_shop_for_me = 'app/user/shop_for_me';

    //帮送、取
    var user_ship_for_me = 'app/user/ship_for_me';

    //帮忙
    var user_help = 'app/user/help';
</script>